package com.sdyd.antivirus.controller;

import com.alibaba.fastjson.JSONObject;
import com.sdyd.antivirus.service.CommunityInfoService;
import com.sdyd.antivirus.service.OfficeBuildingInfoService;
import com.sdyd.antivirus.service.StatisticsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * @author liujia
 * @date 2020/2/1 19:19
 **/
@Controller
@RequestMapping("/getresult")
public class StatisticsController {
    Logger logger= LoggerFactory.getLogger(StatisticsController.class);
    @Autowired
    private StatisticsService statisticsService;
    @Autowired
    private CommunityInfoService communityService;
    @Autowired
    private OfficeBuildingInfoService officeBuildingInfoService;

    @RequestMapping("/getstatisres")
    @ResponseBody
    public JSONObject getUserData(String groupId,String startDate,String endDate){
        JSONObject userData = statisticsService.getUserData(groupId,startDate,endDate);
        return userData;
    }
    @RequestMapping(value="/exportdata")
    public void exportData(String groupId,String startdate,String enddate, HttpServletResponse response){
        statisticsService.exportData(groupId, startdate,enddate, response);
    }

    /**
     * 获取小区数据支撑图表
     * @param groupId
     * @param startDate
     * @param endDate
     * @return
     */
    @RequestMapping("/getcommunitydata")
    @ResponseBody
    public JSONObject getCommunityData(String groupId,String startDate,String endDate){
        JSONObject userData = communityService.getUserData(groupId,startDate,endDate);
        return userData;
    }

    @RequestMapping(value="/exportcommunitydata")
    public void exportCommunityData(String groupId,String startDate,String endDate, HttpServletResponse response){
        communityService.exportData(groupId, startDate,endDate, response);
    }

    /**
     * 获取写字楼数据支撑图表
     * @param groupId
     * @param startDate
     * @param endDate
     * @return
     */
    @RequestMapping("/getofficebuildingdata")
    @ResponseBody
    public JSONObject getOfficeBuildingData(String groupId,String startDate,String endDate){
        JSONObject userData = officeBuildingInfoService.getUserData(groupId,startDate,endDate);
        return userData;
    }
    @RequestMapping("/exportofficebuildingdata")
    @ResponseBody
    public void exportOfficeBuildingData(String groupId,String startDate,String endDate, HttpServletResponse response){
        officeBuildingInfoService.exportData(groupId, startDate,endDate, response);
    }
}
